package com.hjc.springbootstudyweb.controller;

import com.hjc.springbootstudyweb.entity.UsersModel;
import com.hjc.springbootstudyweb.mapper.UsersMapper;
import com.hjc.springbootstudyweb.service.ServiceImpl.UsersServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: HJC
 * Date: 2019/11/29
 * Time: 8:28
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("/users")
public class T9CtlTest {
    @Autowired
    private UsersServiceImpl usersService;

    @RequestMapping(value = "/queryInfo", method = RequestMethod.POST)
    public String index(Model model,String uid ,String password){
        UsersModel usersModel = usersService.queryById(uid,password);
        if(usersModel != null){
            List<UsersModel> list = usersService.queryAll();
            for (UsersModel usersModel1 : list) {
                System.out.println(usersModel1);
            }
            model.addAttribute("list",list);
            return "html/info";
        }else{
            return "redirect:/";
        }
    }
}
